package com.younion.business.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.younion.business.IOperateLogService;
import com.younion.common.exception.BaseException;
import com.younion.common.paginator.Paginator;
import com.younion.dao.OperateLogDAO;
import com.younion.vo.OperateLogVO;

import cpcns.jhsks.util.MapCollectionUtils;

public class OperateLogServiceImpl extends BaseService implements IOperateLogService {
	
	protected static final Log logger = LogFactory.getLog(OperateLogServiceImpl.class);
	
	private OperateLogDAO operateLogDAO;

	public List get(Map paramMap, Paginator paginator) throws Exception {
		if (MapCollectionUtils.isEmpty(paramMap))
			return null;
		try {
			Map map = new HashMap();
			map.put("paramMap", paramMap);
			return this.operateLogDAO.selectForPage(map, paginator);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(
					OperateLogServiceImpl.class.getName()
							+ " >> public Page get(Map paramMap, Integer curPage, Integer pageSize) error occur:",
					e);
		}
	}

	public int getCountByMap(Map paramMap) throws BaseException {
		try {
			return this.operateLogDAO.selectCountByMap(paramMap);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(OperateLogServiceImpl.class.getName()
					+ " >> public Collection getCountByMap(Map map) error occur:", e);
		}
	}

	public OperateLogVO save(OperateLogVO voObject) throws Exception {
		if (voObject == null)
			return null;
		try {
			voObject.setUserVO(this.getCurrectUser());
			return (OperateLogVO) this.operateLogDAO.insertByVo(voObject);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			throw new BaseException(UserServiceImpl.class.getName()
					+ " >> public OperateLogVO save(OperateLogVO voObject) error occur:", e);
		}
	}
	
	public void setOperateLogDAO(OperateLogDAO operateLogDAO) {
		this.operateLogDAO = operateLogDAO;
	}
	
	public OperateLogDAO getOperateLogDAO() {
		return this.operateLogDAO;
	}

}
